<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>管理登录</title>
    <!-- 引入 jQuery 库 -->
    <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <style>
        /* 全局样式，设置字体和背景颜色 */
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f4f4f9;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }

        /* 登录框样式 */
        #divstyle {
            background-color: #fff;
            padding: 40px;
            border-radius: 8px;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
            width: 300px;
        }

        /* 标题样式 */
        h2 {
            text-align: center;
            color: #333;
            margin-bottom: 30px;
        }

        /* 输入框容器样式 */
        .input-container {
            margin-bottom: 20px;
        }

        /* 输入框标签样式 */
        .input-container label {
            display: block;
            margin-bottom: 5px;
            color: #666;
        }

        /* 输入框样式 */
        .input-container input {
            width: 100%;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
        }

        /* 按钮样式 */
        button {
            width: 100%;
            padding: 10px;
            background-color: #007BFF;
            color: #fff;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        /* 按钮悬停样式 */
        button:hover {
            background-color: #0056b3;
        }
    </style>
</head>

<body>
    <div id="divstyle">
        <h2>管理登录</h2>
        <div class="input-container">
            <label for="name">账号</label>
            <input type="text" name="user" placeholder="请输入账号" id="name">
        </div>
        <div class="input-container">
            <label for="pwd">密码</label>
            <input type="password" name="pwd" placeholder="请输入密码" id="pwd">
        </div>
        <button onclick="sub()">提交</button>
    </div>
    <script>
        function sub() {
            var name = document.getElementById("name").value;
            var pwd = document.getElementById("pwd").value;
            if (name == null || name.trim() == "") {
                alert("账号格式错误,请重新输入");
                return;
            }
            if (pwd == null || pwd.trim() == "") {
                alert("密码格式错误,请重新输入");
                return;
            }
            var user = {
                username: name,
                password: pwd
            };
            var userdata = JSON.stringify(user);
            $.post("http://localhost:8080/bank/login1", { "userdata": userdata }, function (data) {
                alert(data);
                if (data === "登录成功") {
                    window.open("http://localhost:8080/bank/登录成功.html", "_self");
                }
            });
        }
    </script>
</body>

</html>